<?php
class Managecategory_Model_Categoryactions {
	
	private $secure;
	private $editForm;
	private $addForm;
	private $addedAction;
	private $removeAction;
	private $updateAction;
	
	public function __construct(){
		$this->secure = new Core_Data_Secure();
		$this->editForm = new Managecategory_Data_Editform;
		$this->addForm = new Managecategory_Data_Addform;
		$this->addedAction = new Managecategory_Data_Addedaction;
		$this->removeAction = new Managecategory_Data_Removeaction;
		$this->updateAction = new Managecategory_Data_Editaction;
	}
	
	public function getAction(array $getVars, array $postVars){
		try {
			$postVars = $this->secure->parseData($postVars);
			$getVars = $this->secure->parseData($getVars);
			$page = $getVars['page'];
			switch($page){
				case "update":
					$this->updateAction->updateValues($postVars);
					break;
				case "edit":
					return $this->editForm->getForm($getVars);
					break;
				case "add":
					return $this->addForm->getForm();
					break;
				case "added":
					$this->addedAction->addValues($postVars);
					break;
				case "remove":
					$this->removeAction->removeValues($getVars);
					break;
				default:
					echo '<meta http-equiv="Refresh" content="0;url='.SERVER_ROOT.'?managecategory">';
					break;
			}
			
		}
		catch(Exception $e){
			echo $e->getMessage();
		}
	}
	
}